package com.liruo.learn.spring.mvc.controller;

import com.liruo.learn.spring.mvc.model.enumeration.GenderEnum;
import com.liruo.learn.spring.mvc.model.req.ConverterReq;
import com.liruo.learn.spring.mvc.model.vo.ConverterVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

/**
 * @Author:liruo
 * @Date:2023-02-19-14:40:39
 * @Desc
 */
@RestController
@Slf4j
@RequestMapping("/converter")
public class ConverterController {
    @PostMapping("/post")
    public ConverterVo post(ConverterReq converterReq){
        ConverterVo converterVo = new ConverterVo();
        BeanUtils.copyProperties(converterReq, converterVo);
        return converterVo;
    }
    @GetMapping("/get")
    public ConverterVo get(ConverterReq converterReq){
        ConverterVo converterVo = new ConverterVo();
        BeanUtils.copyProperties(converterReq, converterVo);
        return converterVo;
    }
    @PostMapping("/post/body")
    public ConverterVo postBody(@RequestBody ConverterReq converterReq){
        ConverterVo converterVo = new ConverterVo();
        BeanUtils.copyProperties(converterReq, converterVo);
        return converterVo;
    }

    @PostMapping("/spring/post")
    public GenderEnum defaultPost(GenderEnum genderEnum){
        ConverterVo converterVo = new ConverterVo();
        return genderEnum;
    }
}
